<?php

declare(strict_types=1);

namespace App\Common\Helpers;

class Ip2Region extends \Mine\Helper\Ip2region
{
    public function searchByIp(string $ip): array
    {
        $region = $this->searcher->search($ip);

        $result = [
            'province' => '',
            'city' => ''
        ];

        if (! $region) {
            return $result;
        }

        [$country, $number, $province, $city, $network] = explode('|', $region);
        if ($country == '中国') {
            $result = [
                'province' => $province,
                'city' => $city
            ];
            return $result;
        }
        return $result;
    }

}